package com.lagou.controller;

import com.lagou.mapper.ArticleMapper;
import com.lagou.pojo.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Calendar;
import java.util.List;

@Controller
public class LoginController {
    @Autowired
    private ArticleMapper articleMapper;

    @RequestMapping("/toLoginPage")
    public String toLoginPage(Model model){

        model.addAttribute("currentYear", Calendar.getInstance().get(Calendar.YEAR));
        return "login";
    }


    @RequestMapping("/toIndex")
    public String toIndex(Model model){

        List<Article> articles = articleMapper.listArticle();

        model.addAttribute("articles", articles);
        return "client/index";
    }
}
